﻿@model DLMemberPointMS.Entity.ViewModel.UsersViewModel
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>修改个人资料</title>
    <link rel="stylesheet" type="text/css" href="~/layui/css/layui.css" />
    <script src="~/layui/layui.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
    <div style="margin:5px">
        <form class="layui-form" id="userInfo">
            <fieldset class="layui-elem-field">
                <legend>用户基本资料</legend>
                <div class="layui-field-box" id="form" style="border:5px">
                    <div class="layui-input-inline">
                        <label class="layui-form-label">登录名：</label>
                        <div class="layui-input-block">
                            @Html.EditorFor(model => model.U_LoginName, new { htmlAttributes = new { @class = "layui-input", lay_verify = "required" } })
                            @Html.EditorFor(model => model.U_ID, new { htmlAttributes = new { hidden = "hidden" } })
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="layui-input-inline">
                        <label class="layui-form-label">真实姓名：</label>
                        <div class="layui-input-block">
                            @Html.EditorFor(model => model.U_RealName, new { htmlAttributes = new { @class = "layui-input", lay_verify = "required" } })
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="layui-input-inline">
                        <label class="layui-form-label">性别：</label>
                        <div class="layui-input-block">
                            @Html.RadioButtonFor(u => u.U_Sex, 1, new { title = "男" })
                            @Html.RadioButtonFor(u => u.U_Sex, 0, new { title = "女" })
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="layui-input-inline">
                        <label class="layui-form-label">联系电话：</label>
                        <div class="layui-input-block">
                            @Html.EditorFor(model => model.U_Telephone, new { htmlAttributes = new { @class = "layui-input", lay_verify = "phone" } })
                        </div>
                    </div>
                    <br />
                    <br />
                    <div class="layui-input-inline">
                        <div class="layui-btn-container">
                            <label class="layui-form-label"></label>
                            <button type="button" class="layui-btn layui-btn-sm" id="submit" lay-submit lay-filter="submitform"><i class="layui-icon">确定</i></button>
                            <button type="button" class="layui-btn layui-btn-sm" id="close"><i class="layui-icon">关闭</i></button>
                        </div>
                    </div>
                </div>
            </fieldset>
        </form>
    </div>
    <script>
        layui.use(['layer', 'form', 'jquery'], function () {
            var layer = layui.layer,
                form = layui.form,
                $ = layui.jquery;

            form.on('submit(submitform)', function (data) {
                var FormData = $('#userInfo').serializeArray();
                $.ajax({
                    url: '/Users/ChangeUserInfo',
                    type: 'post',
                    data: FormData,
                    success: function (data) {
                        if (data.code == 0) {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                            parent.layer.msg(data.msg, { icon: 1 })
                        } else {
                            layer.msg(data.msg, { icon: 2 })
                        }
                    },
                    error(data) {
                        layer.msg('网络错误，请重试', { icon: 2 })
                    }

                })
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });

            $('#close').click(function () {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            })
        })
    </script>
</body>
</html>
